package com.mmall.concurrency.example.syncContainer;

import com.mmall.concurrency.annoations.NotThreadSafe;

import java.util.List;
import java.util.Vector;

/**
 * Created by RID on 2018/4/13.
 */
@NotThreadSafe
public class VectorExample {

    private final static List<Integer> vector= new Vector<>();

    public static void main(String[] args) {
        while (true){
            for (int i=0; i<10; i++){
                vector.add(i);
            }


            Thread thread= new Thread(){
                @Override
                public void run() {
                    for (int i=0; i<vector.size();i++)
                    vector.remove(i);
                }

            };

            Thread thread1= new Thread(){
                @Override
                public void run() {
                    for (int i=0; i<vector.size();i++)
                    vector.get(i);
                }
            };

            thread.start();
            thread1.start();
        }
    }


}
